!-----------------------------------------------!
!       A. Gazizov, LNGS, INFN, 07.12.10        ! 
!-----------------------------------------------!

module genfun
   use commirr, only: gam    &  ! index of generation function
                    , rqqmir &  ! Q/Q_mirr
					, xmax		! ln(E_max/E_0)
   implicit none

   real(8):: qgen, qgenmirr

!-----------------------------------------------
            CONTAINS
!-----------------------------------------------

!********************************
! hz = H(z)/H_0
   Subroutine Generation(x, hz)
      implicit none
	  real(8), intent(in):: x, hz
 !  
      if(x.lt.0d0) then
	     qgen  = dexp(-2d0*x)
      elseif(x.lt.xmax) then
	     qgen  = dexp(-gam*x)
      else
	     qgen = 0d0 
	  endif   

	  qgen = qgen/hz

	  qgenmirr = rqqmir*qgen

   end Subroutine Generation
!********************************

end module genfun